<script name='Project' setup>
import {
    queryProjectListApi,
    addProjectApi,
    updateProjectApi,
    delProjectApi,
    queryProjectNameApi,
    updateProjectStatusApi
} from '@/api/business/project'
import { computed, reactive, ref } from 'vue'
import useUserStore from '@/store/modules/user'
import useCommonStore from '@/store/modules/common'
const userStore = useUserStore()
const commonStore = useCommonStore()
const { proxy } = getCurrentInstance()
const { business_project_status } = proxy.useDict('business_project_status')
//查询
const showSearch = ref(true)
const dateRange = ref([])
const queryParams = ref({
    pageNum: 1,
    pageSize: 10,
    projectName: void 0,
    status: void 0,
    leader: [],
    member: []
})
const total = ref(0)

const queryLeaderList = computed(() => commonStore.userList.filter(item => !queryParams.value.member.includes(item.userId)))
const queryMemberList = computed(() => commonStore.userList.filter(item => !queryParams.value.leader.includes(item.userId)))

/** 搜索按钮操作 */
function handleQuery() {
    queryParams.value.pageNum = 1
    let leaderStr = queryParams.value.leader.join(',')
    let memberStr = queryParams.value.member.join(',')
    getList({ ...proxy.addDateRange(queryParams.value, dateRange.value), leader: leaderStr, member: memberStr })
}
/** 重置按钮操作 */
function resetQuery() {
    proxy.resetForm('queryRef')
    dateRange.value = []
    handleQuery()
}




//查询项目量化列表
const loading = ref(false)
const scoreList = ref([])
/** 查询项目列表 */
async function getList(params) {
    loading.value = true
    const { data } = await queryProjectListApi(params)
    console.log(data, '项目列表')
    projectList.value = data.list
    total.value = data.total
    loading.value = false
}
</script>

<template>
    <div class='app-container'>
        <el-table v-loading="loading" :data="scoreList">
            <el-table-column label="成员" prop="leader">
                <template #default="{ row }">
                    <div style="display: flex;gap: 2%;justify-content: center;align-items: center;">
                        <el-tag v-for="item in row.leader" :key="item.userId" class="mr-2" type="success">{{
                            item.nickName
                        }}
                        </el-tag>
                    </div>
                </template>
            </el-table-column>
            <el-table-column label="量化分分配" prop="member">
                <template #default="{ row }">
                    <div class="flex-center" style="gap: 2%;">

                    </div>
                </template>
            </el-table-column>
            <el-table-column label="进度" prop="status" width="180">
                <template #default="{ row }">
                    <div class="flex-center" style="gap: 4%;">
                        <dict-tag :options="business_project_status" :value="row.status" />
                    </div>
                </template>
            </el-table-column>
            <el-table-column label="创建时间" prop="createTime" width="180">
                <template #default="{ row }">
                    <span>{{ parseTime(row.createTime) }}</span>
                </template>
            </el-table-column>
            <el-table-column label="开始时间" prop="createTime" width="180">
                <template #default="{ row }">
                    <span>{{ parseTime(row.beginTime) || '- -' }}</span>
                </template>
            </el-table-column>
            <el-table-column label="结束时间" prop="createTime" width="180">
                <template #default="{ row }">
                    <span>{{ parseTime(row.endTime) || '- -' }}</span>
                </template>
            </el-table-column>
            <el-table-column class-name="small-padding fixed-width" label="操作">
                <template #default="{ row }">
                    <el-button v-hasPermi="['business:project:edit']" icon="Edit" link type="primary"
                        @click="handleUpdate(row)">修改
                    </el-button>
                </template>
            </el-table-column>
        </el-table>

        <pagination v-show="total > 0" v-model:limit="queryParams.pageSize" v-model:page="queryParams.pageNum"
            :total="total" @pagination="getList" />
    </div>
</template>

<style lang='scss' scoped>
.flex-center {
    display: flex;
    justify-content: center;
    align-items: center;
}
</style>
